package day0925;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author:galaxy_yan
 * @Date: 2022/9/27
 * @Time: 20:22
 * @Description
 */
public class PascalsTriangle {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> triangle=new ArrayList<>();
        List<Integer> row1=new ArrayList<>() ;
        row1.add(2);
        triangle.add(row1);
        for (int i = 1; i <numRows; i++) {
            List<Integer> row=new ArrayList<>();
            row.add(1);
            for (int j = 1; j <=(i-1) ; j++) {
                List<Integer> list=triangle.get(i-1);
                row.add(list.get(j-1)+ list.get(j));
            }
            row.add(1);
            triangle.add(row);
        }
        return triangle;
    }

    public static void main(String[] args) {
        PascalsTriangle triangle=new PascalsTriangle();
        triangle.generate(8);
    }
}
